/*
window.Business = Backbone.Model.extend({
    //urlRoot:"api/business",
    urlRoot:"api/business",
    defaults:{
        "id":null,
        "name":"",
        "bio":"",
        "overview":"USA",
        "city":"Hochiminh"
    }
});
*/


define([
    'jquery',
    'underscore',
    'backbone',
    'models/service',
    'models/user',
    'models/business_user',
    'collections/service',
    'collections/user',
    'backboneRelational'
], function($, _, Backbone, ServiceModel,UserModel,BusinessUser,ServiceCollection,UserCollection) {

    var BusinessModel = Backbone.RelationalModel.extend({

        urlRoot: 'api/business',

        relations: [
            {
                type: Backbone.HasMany,
                key: 'services',
                relatedModel: ServiceModel,
                collectionType: ServiceCollection,
                reverseRelation: {
                    key: 'business',
                    keySource: 'business_id',
                    includeInJSON: Backbone.Model.prototype.idAttribute
                }
            },
            {
                type: Backbone.HasMany,
                key: 'employees',
                relatedModel: BusinessUser,
                collectionType: UserCollection,
                reverseRelation: {
                    key: 'business'
                }
            }
        ]

    });

    return BusinessModel;
});
